//
//  RecommendParser.m
//  EasyBuy
//
//  Created by Zhu Xiangjun on 10/5/12.
//  Copyright (c) 2012 shen donghao. All rights reserved.
//

#import "RecommendParser.h"

@implementation RecommendParser

-(NSArray *)excuteToObjects:(NSDictionary *)itemFeeds{
    
    NSMutableArray *feedsArray = [[[NSMutableArray alloc] init] autorelease];
    NSArray *recommendList = [itemFeeds objectForKey:@"recommend_list"];
    int count =[recommendList count];
    
    for(int i = 0 ; i < count ; i++){
        
        RecommendData *recommendData = [[RecommendData alloc] init];
        NSDictionary *recommendDic =[recommendList objectAtIndex:i];
        recommendData.recommendid = [[recommendDic objectForKey:@"recommend_list"] intValue];
        recommendData.recommendtitle = [recommendDic objectForKey:@"recommendtitle"];
        recommendData.recommendItemsArray = [[NSMutableArray alloc] init];
        NSArray *subjectActorFeeds  = [recommendDic objectForKey:@"recommendcontentlist"];
        
        int subCount = [subjectActorFeeds count];
        
        for( int j = 0 ; j < subCount ; j++){
            NSDictionary *subDic =[subjectActorFeeds objectAtIndex:j];
            RecommendItemData *itemData =  [[RecommendItemData alloc] init];
            itemData.contentid    = [[subDic objectForKey:@"id"] intValue];
            itemData.price        = [[subDic objectForKey:@"price"]intValue];
            itemData.officalprice = [[subDic objectForKey:@"officalprice"] intValue];
            itemData.title = [subDic objectForKey:@"title"];
            itemData.image        = [subDic objectForKey:@"image"];
            itemData.location     = [subDic objectForKey:@"location"];
            itemData.time         = [subDic objectForKey:@"time"];
            [recommendData.recommendItemsArray addObject:itemData];
            [itemData release];
        }

        [feedsArray addObject:recommendData];
        [recommendData release];
        
    }
    
    return feedsArray;
}

@end
